package Com.Hupochuan.Dal.Tab;

import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

import Com.Hupochuan.Dal.DBManager.DBManager;
import Com.Hupochuan.Vo.MovieActor;

public class MovieActorTab {
	/*
	 * 本类私有对象
	 */
	private DBManager<MovieActor> dbManager = new DBManager<MovieActor>(MovieActor.class);
	
	/*
	 * 单一实例
	 */
	private MovieActorTab(){}
	private static MovieActorTab movieActorTab = new MovieActorTab();
	public static MovieActorTab getObject(){
		return movieActorTab;
	}
	
	/*
	 * 电影演员列表
	 */
	public List<MovieActor> findMovieActorList(long movieId){
		
		//参数部分
		List<MovieActor> movieActorList = new Vector<MovieActor>();
		StringBuffer sqlBuff = new StringBuffer();
		Hashtable<String,Object> paraHash = new Hashtable<String,Object>();
		
		//sql语句部分
		sqlBuff.append(" select MovieActor.*, ");
		sqlBuff.append(" 	Actor.name as actorName, ");
		sqlBuff.append(" 	Actor.logoPath as actorLogoPath, ");
		sqlBuff.append(" 	Actor.baikeUrl as actorBaikeUrl, ");
		sqlBuff.append(" 	Actor.xlwbUrl as actorXlwbUrl, ");
		sqlBuff.append(" 	Actor.txwbUrl as actorTxwbUrl, ");
		sqlBuff.append(" 	Actor.bdtbUrl as actorBdtbUrl ");
		sqlBuff.append(" from MovieActor  ");
		sqlBuff.append(" left join Actor on MovieActor.actorId=Actor.id ");
		sqlBuff.append(" where MovieActor.movieId=${movieId} ");
		sqlBuff.append(" order by ");
		sqlBuff.append(" 	MovieActor.weight desc, ");
		sqlBuff.append(" 	Actor.weight desc, ");
		sqlBuff.append(" 	Actor.id, ");
		sqlBuff.append(" 	MovieActor.id ");
		
		//sql参数部分
		paraHash.put("movieId",movieId);
		
		//执行sql 
		movieActorList = this.dbManager.querySqlReturnVoList(sqlBuff.toString(),paraHash);
		
		//返回列表
		return movieActorList;
	}
}
